﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Xpom_Xpum__Integrated_Development_Environment.View
{
    /// <summary>
    /// Interaction logic for AddBrowserWindowView.xaml
    /// </summary>
    public partial class AddBrowserWindowView : Window
    {
        public AddBrowserWindowView()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new System.Windows.Forms.OpenFileDialog();

            ofd.Filter = "Recommended browsers (Chrome, Comodo Dragon, SRWare Iron, Uran, Yandex)|chrome.exe;dragon.exe;uran.exe;browser.exe|All EXE files|*.exe|*.*|*.*";
            
            var result = ofd.ShowDialog(((App)App.Current).MainWindow as System.Windows.Forms.IWin32Window);

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                string browserPath = ofd.FileName;

                textBox3.Text = browserPath;
            }
        }

        /// <summary>
        /// Cancel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void textBox3_TextChanged(object sender, TextChangedEventArgs e)
        {
            button3.IsEnabled = !String.IsNullOrEmpty(textBox3.Text);
        }

        /// <summary>
        /// OK
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            ((App)App.Current).iswvm.AddBrowser(textBox1.Text, textBox2.Text, textBox3.Text);
            this.Close();
        }
    }
}
